package cn.zysuyuan.item.service.impl;

import cn.zysuyuan.item.config.HttpClient;
import cn.zysuyuan.item.service.EasyMockDataService;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * @author flypig
 * @version 1.0
 * @date 2020-04-05 16:55
 */

@Service
public class EasyMockDataServiceImpl implements EasyMockDataService {


    @Override
    public JSONObject getWarningMess() {
        String url = "http://mengxuegu.com:7300/mock/5e893ad01c5f7f209577b886/warning/mess";
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        HttpHeaders headers = new HttpHeaders();
        String response = HttpClient.sendGetRequest(url,params,headers);
        JSONObject json = JSONObject.parseObject(response);
        return json;
    }

    @Override
    public JSONObject getTypeMess() {
        String url = "http://mengxuegu.com:7300/mock/5e893ad01c5f7f209577b886/all/mess";
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        HttpHeaders headers = new HttpHeaders();
        String response = HttpClient.sendGetRequest(url,params,headers);
        JSONObject json = JSONObject.parseObject(response);
        return json;
    }

    @Override
    public JSONObject getTableData() {
        String url = "http://mengxuegu.com:7300/mock/5e893ad01c5f7f209577b886/data/today";
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        HttpHeaders headers = new HttpHeaders();
        String response = HttpClient.sendGetRequest(url,params,headers);
        JSONObject json = JSONObject.parseObject(response);
        return json;
    }

    @Override
    public JSONObject selectTableData() {
        String url = "http://mengxuegu.com:7300/mock/5e893ad01c5f7f209577b886/data/today/select";
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        HttpHeaders headers = new HttpHeaders();
        String response = HttpClient.sendGetRequest(url,params,headers);
        JSONObject json = JSONObject.parseObject(response);
        return json;
    }

    @Override
    public JSONObject getAllDevice() {
        String url = "http://mengxuegu.com:7300/mock/5e893ad01c5f7f209577b886/mess/device";
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        HttpHeaders headers = new HttpHeaders();
        String response = HttpClient.sendGetRequest(url,params,headers);
        JSONObject json = JSONObject.parseObject(response);
        return json;
    }
}
